.TH std::tm 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::tm \- std::tm

.SH Synopsis
   Defined in header <ctime>
   struct tm;

   Structure holding a calendar date and time broken down into its components.

.SH Member objects

                seconds after the minute –
                [0, 61]
   int tm_sec   \fI(until C++11)\fP
                [0, 60]
                \fI(since C++11)\fP^[note 1]
                \fI(public member object)\fP
   int tm_min   minutes after the hour – [0, 59]
                \fI(public member object)\fP
   int tm_hour  hours since midnight – [0, 23]
                \fI(public member object)\fP
   int tm_mday  day of the month – [1, 31]
                \fI(public member object)\fP
   int tm_mon   months since January – [0, 11]
                \fI(public member object)\fP
   int tm_year  years since 1900
                \fI(public member object)\fP
   int tm_wday  days since Sunday – [0, 6]
                \fI(public member object)\fP
   int tm_yday  days since January 1 – [0, 365]
                \fI(public member object)\fP
                Daylight Saving Time flag. The value is positive if DST is in effect,
   int tm_isdst zero if not and negative if no information is available.
                \fI(public member object)\fP

.SH Notes

   The Standard mandates only the presence of the aforementioned members in some order.
   The implementations usually add more data members to this structure.

    1. ↑ Range allows for a positive leap second. Two leap seconds in the same minute
       are not allowed (the range [0, 61] was a defect introduced in C89 and corrected
       in C99).

.SH Example


// Run this code

 #include <ctime>
 #include <iostream>

 int main()
 {
     std::tm tm{};
     tm.tm_year = 2022 - 1900;
     tm.tm_mday = 1;
     std::mktime(&tm);

     std::cout << std::asctime(&tm); // note implicit trailing '\\n'

     std::cout << "sizeof(std::tm) = " << sizeof(std::tm) << '\\n'
               << "sum of sizes of standard members = "
               << sizeof(tm.tm_sec) +
                  sizeof(tm.tm_min) +
                  sizeof(tm.tm_hour) +
                  sizeof(tm.tm_mday) +
                  sizeof(tm.tm_mon) +
                  sizeof(tm.tm_year) +
                  sizeof(tm.tm_wday) +
                  sizeof(tm.tm_yday) +
                  sizeof(tm.tm_isdst) << '\\n';
 }

.SH Possible output:

 Sat Jan  1 00:00:00 2022
 sizeof(std::tm) = 56
 sum of sizes of standard members = 36

.SH See also

   localtime converts time since epoch to calendar time expressed as local time
             \fI(function)\fP
             converts time since epoch to calendar time expressed as Universal
   gmtime    Coordinated Time
             \fI(function)\fP
   C documentation for
   tm
